package socdev.mobile;

import socdev.data.User;
import socdev.data.UsersContainer;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class LoginActivity extends Activity{

	private UsersContainer users = new UsersContainer();
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.login);
        
        users.update();
        
        
        
        Button logButton = (Button) findViewById(R.id.log_button);
        logButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                String nick =((TextView) findViewById(R.id.name)).getText().toString();
                if(users.contains(nick)) {
                	Intent myIntent = new Intent(view.getContext(), ProjectActivity.class);
                	myIntent.putExtra("user", users.get(nick));
                	startActivityForResult(myIntent, 0);
                } else {
                	TextView info = (TextView) findViewById(R.id.log_info);
                	info.setText("Uživatel neexistuje");
                	
                }
            	
            	
            	
                
                
                
            }

        });
        
        
       
        
       
        
        
    }
	
}
